#pragma once

#include "IXFixedBuffer.h"
#include "SkinDataDef.h"
#include <Skin/Include/IXFont.h>
#include <Skin/Include/IXTextEnv.h>

namespace DrawUtil
{
    ExportXSkinLib BOOL    GetXImageSize(IN XIMAGE xImage, OUT LPSIZE pSize);
    ExportXSkinLib BOOL    GetXIconSize(IN XICON xIcon, OUT LPSIZE pSize);
    ExportXSkinLib DWORD   GetImageBits(IN XIMAGE xImage);

    ExportXSkinLib HRESULT BitDraw(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes);
    ExportXSkinLib HRESULT DefinedAlphaDraw(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes);
    ExportXSkinLib HRESULT ValuedAlphaDraw(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, IN BYTE byAlphaValue);
    ExportXSkinLib HRESULT TransparentDraw(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, IN COLORREF clrTrans);
    ExportXSkinLib HRESULT TransparentAlphaDraw(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, IN BYTE byAlphaValue, IN COLORREF clrTrans);
    ExportXSkinLib HRESULT TileDraw(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, ImageDrawType type);

    ExportXSkinLib HRESULT BitDrawEx(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, ImageDrawParams* pParam, ImageDrawType type);
    ExportXSkinLib HRESULT DefinedAlphaDrawEx(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, ImageDrawParams* pParam, ImageDrawType type);
    ExportXSkinLib HRESULT ValuedAlphaDrawEx(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, IN BYTE byAlphaValue, ImageDrawParams* pParam, ImageDrawType type);
    ExportXSkinLib HRESULT TransparentDrawEx(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, IN COLORREF clrTrans, ImageDrawParams* pParam, ImageDrawType type);
    ExportXSkinLib HRESULT TransparentAlphaDrawEx(IN XCANVAS xCanvas, IN XIMAGE xImage, IN const RECT* lpSrc, IN const RECT* lpDes, IN BYTE byAlphaValue, IN COLORREF clrTrans, ImageDrawParams* pParam, ImageDrawType type);

    ExportXSkinLib HRESULT DrawIcon(XCANVAS xCanvas, XICON xIcon, const RECT* lpDes);

    ExportXSkinLib HRESULT XIcon2XImage(IN XICON xIcon, IN BOOL bBigIcon, OUT XIMAGE* pImage);

    ExportXSkinLib HRESULT LoadXImageFromFixedBuffer(IN IXFixedBuffer* pBuffer, OUT XIMAGE* pxImage);
    ExportXSkinLib HRESULT LoadXIconFromFixedBuffer(IN IXFixedBuffer* pBuffer, OUT XICON* pxIcon, IN BOOL bBigIcon);
    ExportXSkinLib HRESULT LoadXIconImageFromPEFile(IN LPCTSTR szPath, OUT XIMAGE* pxImage, IN BOOL bBigIcon);
    ExportXSkinLib HRESULT LoadXIconImageFromIconFile(IN LPCTSTR szPath, OUT XIMAGE* pxImage, IN BOOL bBigIcon);
    ExportXSkinLib HRESULT LoadXIconImageFromFixedBuffer(IN IXFixedBuffer* pBuffer, OUT XIMAGE* pxImage, IN BOOL bBigIcon);

    ExportXSkinLib void    DrawLine(XCANVAS xCanvas, const POINT& PtSrc, const POINT& PtDes, COLORREF clrLine);
    ExportXSkinLib void    FillRect(XCANVAS xCanvas, const RECT* prc, COLORREF clr);
    ExportXSkinLib void    Rectangle(XCANVAS xCanvas, const RECT* lpRect, COLORREF clrRect);
    ExportXSkinLib void    Rectangle(XCANVAS xCanvas, const RECT* lpRect, COLORREF clrRect, COLORREF clrFill);
    ExportXSkinLib void    Rectangle(XCANVAS xCanvas, const RECT* lpRect, COLORREF clrRect, int nBorder);
    ExportXSkinLib void    Rectangle(XCANVAS xCanvas, const RECT* lpRect, COLORREF clrRect, COLORREF clrFill, int nBorder);
    ExportXSkinLib void    DrawGradient(XCANVAS xCanvas, const RECT& rcRect, COLORREF rgbTop, COLORREF rgbBottom, BOOL bVert = TRUE);

    ExportXSkinLib void    DrawFocusRect(XCANVAS xCanvas, const RECT* lpRect);

    ExportXSkinLib void    RoundRectangle(XCANVAS xCanvas, const RECT* lpRect, COLORREF clrRect, int nWidth, int nHeight);
    ExportXSkinLib void    RoundRectangle(XCANVAS xCanvas, const RECT* lpRect, COLORREF clrRect, COLORREF clrFill, int nWidth, int nHeight);

    ExportXSkinLib XIMAGE  CreateImage(XCANVAS xCanvas, int nWidth, int nHeight);
    ExportXSkinLib XIMAGE  CreateImage(int nBitsPerPixel, int nWidth, int nHeight);
    ExportXSkinLib XIMAGE  CreateTransparentImage(int nWidth, int nHeight);
    ExportXSkinLib XIMAGE  MakeImageTransparent(XIMAGE xImage, const RECT* prc);
    ExportXSkinLib void    DeleteImage(XIMAGE& xImage);

    ExportXSkinLib void    GetTriangleSize(OUT LPSIZE pSize);
    ExportXSkinLib void    DrawTriangle(XCANVAS xCanvas, int x, int y, BOOL bUp);

    ExportXSkinLib BOOL    XDrawText(XCANVAS canvas, LPCTSTR szText, size_t nLength, LPRECT prcText, IXTextEnv* pTextEnv, IXFont* pFont);

    // pTextSize, In: cx means maxwidth.
    ExportXSkinLib BOOL    XGetTextSize(LPCTSTR szText, size_t nLength, IN OUT LPSIZE pTextSize, IXFont* pFont, IXTextEnv* pTextEnv);
    ExportXSkinLib BOOL    XGetTextSize(XCANVAS xCanvas, LPCTSTR szText, size_t nLength, IN OUT LPSIZE pTextSize, IXFont* pFont, IXTextEnv* pTextEnv);

    ExportXSkinLib XIMAGE  XCopyImage(XIMAGE xImage, int nWidth, int nHeight);
}
